<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://unpkg.com/vue@next"></script>
  <style>
    .active {
      color: red;
    }
  </style>
</head>
<body>
  <div id="app">
    <button v-for="tab in tabs" :key="tab" :class="{active: currentTab === tab}" @click="currentTab = tab">{{ tab }}</button>
    <component :is="currentTabComponent"></component>
  </div>

  <script>
    const app = Vue.createApp({
      setup() {
        const currentTab = Vue.ref('Home')
        const tabs = Vue.reactive(['Home', 'Post', 'Archive'])
        const currentTabComponent = Vue.computed(() => {
          return 'tab-' + currentTab.value.toLowerCase()
        })
        return {
          currentTab,
          tabs,
          currentTabComponent
        }
      }
    })

    app.component('tab-home', {
      template: `
      <div>
        <p>home component</p>
      </div>
      `
    })
    app.component('tab-post', {
      template: `
      <div>
        <p>post component</p>
      </div>
      `
    })
    app.component('tab-archive', {
      template: `
      <div>
        <p>archive component</p>
      </div>
      `
    })

    app.mount('#app')
  </script>
</body>
</html>